package LeetCode.linkednode;

public class NC_BM8 {
    public ListNode FindKthToTail (ListNode pHead, int k) {
        if (pHead == null){
            return null;
        }
        if(k <= 0){
            return null;
        }
        ListNode fast = pHead;
        ListNode slow = pHead;
        while (k - 1 > 0){
            fast = fast.next;
            if(fast == null){
                return null;
            }
            k--;
        }
        while (fast.next != null){
            fast = fast.next;
            slow = slow.next;
        }
        return slow;
    }
}
